package com.guotd.ticketSystemPlus.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RequiredArgsConstructor
@RestController
@RequestMapping("/api/ai")
public class ChatController {

    private final ChatClient chatClient;
    @RequestMapping(value = "/chat", produces = "text/event-stream;charset=utf-8") // 务必确认这一行！
    public Flux<String> chat(String prompt){
        return chatClient.prompt().user(prompt).stream().content();
    }
}